package com.zjzywl.smoke.repository;


import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.zjzywl.smoke.entity.Role;


@Repository
public interface RoleRepository extends JpaRepository<Role,Integer> {
	@Query("select u from Role u where u.name=:name")
	Role findByRoleName(@Param("name")String name);
//	@Query("select u.roleId from Role u where u.sysUser.loginName=:loginName")
//	int findIdByloginName(@Param("loginName") String loginName);
	@Transactional
	@Modifying
	@Query(value = "update  Role u  set where u.name=:name " ,nativeQuery = true) 
	void updata(@Param("name") String name);
	
	//软删除角色
	@Transactional
	@Modifying
	@Query(value = "update  Role u  set u.Remove='删除' where u.roleId=:roleId ") 
	void deleteRole(@Param("roleId") int id);
	
	@Query("select u from Role u where u.Remove=null")
	List<Role> findAllByRemove();
	
}
